<template id="Student">
  <div>
    <!-- <h2>姓名：{{ name }}</h2>
    <button @click="up">点我有惊喜</button>
    <button @click="post">点我传值</button>
    <button @click="sendvalue">给hello传值</button>
    <button @click="oFF">解绑</button> -->
    <h1>人员列表</h1>
    <h1>求和：{{sum}}</h1>
    <input type="text" placeholder="请输入姓名" v-model="name">
    <button @click="add">添加</button>
    <ul>
      <li v-for="pop in personList" :key="pop.id">{{pop.id}}-{{pop.name}}</li>
    </ul>
  </div>
</template>
<script>
import {nanoid} from 'nanoid'
export default {
  name: "Student",
  data() {
    return {
      name:"",
      // personList:[]
      // name: "大卫",
      // stuname: "妍妍",
      // atring:"hello,I'm Gongyanyan"
    };
  },
  computed:{
    personList(){
      return this.$store.state.studentAbout.personList
    },
    sum(){
      return this.$store.state.countAbout.sum
    }
  },
  // props: ["getName"],
  methods: {
    add(){
      const person={
        id:nanoid(),
        name:this.name
      }
      this.$store.commit("studentAbout/add_person",person)
      this.name=""
    }
    // up() {
    //   this.getName(this.name);
    // },
    // post() {
    //   this.$emit("toparent", this.stuname);
    // },
    // oFF() {
    //   //   this.$off("toparent");
    //   this.$destroy();
    // },
    // sendvalue() {
    //   this.$bus.$emit("demo",this.atring)
    // },
  },
};
</script>